<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    try {
      // 写可能出现报错的代码
      console.log('aaa')
      console.log('bbb')
      JSON.parse('qqq')
      console.log('ccc')
    } catch (error) {
      // 出现代码报错后执行的代码
      console.log(error.message)
      throw new Error('报错了')

      console.log('ddd')
    } finally {
      // 无论代码是否报错，都执行的代码
      console.log('eee')
    }
  </script>
</body>

</html>